package com.hancai.web;

import com.hancai.query.ActivityRemarkQuery;
import com.hancai.result.R;
import com.hancai.service.ActivityRemarkService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 涵菜
 * @version 1.0
 * @RequestBody可以获取请求体，需要在控制器方法设置一个形参，当前请求的请求体
 * 就会为当前注解所标识的形参赋值
 * 用于从 HTTP 请求头（Request Header）中提取信息，并将其绑定到方法参数上。
 */
@RestController
public class ActivityRemarkController {

    @Resource
    private ActivityRemarkService activityRemarkService;

    @PostMapping(value = "/api/activity/remark")
    public R addActivityRemark(@RequestBody ActivityRemarkQuery activityRemarkQuery, @RequestHeader(value = "authorization") String token){
        //axios提交post请求（新增）,提交过来的是json数据，使用@RequestBody注解接收
        activityRemarkQuery.setToken(token);
        int save=activityRemarkService.saveActivityRemark(activityRemarkQuery);
        return save>=1 ? R.OK() : R.FAIL();
    }
}
